version 13.0
log using "C:\Users\mgolder\Dropbox\campaign_sentiment_paper\replication\data_analysis\figure2.log", replace
#delimit ;

*     ***************************************************************** *;
*     ***************************************************************** *;
*       File-Name:      figure2.do                                      *;
*       Date:           January 14, 2019                                *;
*       Author:         MRG/CC                                          *;
*       Purpose:      	Produce Figure 2 for It's Not Only What You     *;
*                       Say, It's Also How You Say It: The Strategic    *;
*                       Use Of Campaign Sentiment. Journal of Politics. *;
*                       Forthcoming.                                    *;
* 	    Input File:     sentiment.dta                                   *;
*       Output File:    figure2.log                                     *;
*       Data Output:    none                                            *;             
*       Previous file:  sentiment.dta                                   *;
*       Machine:        desktop/laptop                     				*;
*     ****************************************************************  *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*        Load data                                                      *;
*     ****************************************************************  *;

use "C:\Users\mgolder\Dropbox\campaign_sentiment_paper\replication\data_analysis\sentiment.dta", clear;

*     ****************************************************************  *;
*       Declare data to be panel, where the panel is based on language  *;
*     ****************************************************************  *;

xtset language;

xtsum positive_sentiment;

*     ****************************************************************  *;
*       Generate additional variables that we will need for our         *;
*       analysis.                                                       *;
*     ****************************************************************  *;

gen incumbent_inflation_l = incumbent*inflation_l;
label var incumbent_inflation "incumbent*inflation_l";
gen incumbent_unemployment_l = incumbent*unemployment_l;
label var incumbent_unemployment_l "incumbent*unemployment_l";
gen incumbent_pm = incumbent*pm;
label var incumbent_pm "incumbent*pm";
gen incumbent_fm = incumbent*fm;
label var incumbent_fm "incumbent*fm";
gen left_right2=left_right*left_right;
label var left_right2 "left_right*left_right";
gen extremist = 0;
replace extremist=1 if family_id ==14 | family_id==40;
replace extremist = . if family_id==.;
label var extremist "1 if communist/socialist or far right, 0 otherwise";
gen extremist2 = 0;
replace extremist2=1 if family_id ==14 | family_id==40 | family_id==19;
replace extremist2 = . if family_id==.;
label var extremist2 "1 if communist/socialist, far right, or greens, 0 otherwise";
gen extremist_inflation_l=extremist*inflation_l;
label var extremist_inflation "extremist*inflation_l";
gen extremist_unemployment_l=extremist*unemployment_l;
label var extremist_unemployment_l "extremist*unemployment_l";

tabulate language, gen(l);

*     ****************************************************************  *;
*      Change graph scheme	                                            *;
*     ****************************************************************  *;

ssc install scheme-burd, replace;

*     ****************************************************************  *;
*     ****************************************************************  *;
*       Produce Figure 2                                                *;
*     ****************************************************************  *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*       Panel A                                                         *;
*     ****************************************************************  *;

graph box positive_emotion, over(language) ytitle("Positive Words Score") scheme(burd);

graph export "C:\Users\mgolder\Dropbox\campaign_sentiment_paper\fig2a.pdf", replace;

*     ****************************************************************  *;
*       Panel B                                                         *;
*     ****************************************************************  *;

graph box negative_emotion, over(language) ytitle("Negative Words Score") scheme(burd);

graph export "C:\Users\mgolder\Dropbox\campaign_sentiment_paper\fig2b.pdf", replace;

*     ****************************************************************  *;
*       Panel C                                                         *;
*     ****************************************************************  *;

graph box positive_sentiment, over(language) ytitle("Positive Sentiment") scheme(burd);

graph export "C:\Users\mgolder\Dropbox\campaign_sentiment_paper\fig2c.pdf", replace;

*     ****************************************************************  *;
*       Replication complete                                            *;
*     ****************************************************************  *;

log close;

clear;

